home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / 3dvect37.zip / FONT.ASM < prev    next >
Assembly Source File  |  1994-06-22  |  14KB  |  512 lines

  1. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2. ;
  3. ; Filename     : font.asm
  4. ; Included from: Main assembley module
  5. ; Description  : Font and cosmetic screen handling routines.
  6. ;                This basically draws backgound screens/opening menus.
  7. ;                Have you played Red Baron or Aces of the Pacific?  It's
  8. ;                kind of like that.
  9. ;
  10. ; Written by: John McCarthy
  11. ;             1316 Redwood Lane
  12. ;             Pickering, Ontario.
  13. ;             Canada, Earth, Milky Way (for those out-of-towners)
  14. ;             L1X 1C5
  15. ;
  16. ; Internet/Usenet:  BRIAN.MCCARTHY@CANREM.COM
  17. ;         Fidonet:  Brian McCarthy 1:229/15
  18. ;   RIME/Relaynet: ->CRS
  19. ;
  20. ; Home phone, (905) 831-1944, don't call at 2 am eh!
  21. ;
  22. ; Send me your protected mode source code!
  23. ; Send me your Objects!
  24. ; But most of all, Send me a postcard!!!!
  25. ;
  26. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  27.  
  28.            .386p
  29.            jumps
  30.  
  31. code32     segment para public use32
  32.            assume cs:code32, ds:code32, ss:code32
  33.  
  34.            include pmode.ext  ; include externals for other modules
  35.            include xmode.ext  ; just in case we ever want to use them...
  36.            include xmouse.ext
  37.            include stars.ext
  38.            include macros.inc
  39.            include 3d.ext
  40.            include equ.inc
  41.  
  42.            include font0.inc  ; font 0
  43.            include font1.inc  ; font 0
  44.            include font2.inc  ; font length tables
  45.  
  46.            public tstring
  47.            public string
  48.            public initfont
  49.  
  50.            public put_at_top
  51.            public number_eax
  52.  
  53. newtext    equ -1
  54. border     equ -2
  55. fillarea   equ -3
  56. hole       equ -4
  57. lowercase  equ -5
  58. uppercase  equ -6
  59. steelbox   equ -7
  60. repeatbit  equ -8
  61. textend    equ 0
  62.  
  63. wcase      db 0                       ; upper/lower case add
  64. colt       dw 0
  65. linecol    dw 0
  66. tw1        dw 0
  67. tq2        dw 0
  68. sinewave   dw 0                       ; sine wave for colour
  69. ltflag     dw 0
  70. brflag     dw 0
  71. q1         dw 0
  72. w1         dw 0
  73. q2         dw 0
  74. w2         dw 0
  75. fontlen    dd 0                       ; offset to font length table
  76.  
  77. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  78. ; TString: Display string of font from [esi] to zero byte on both video pages
  79. ; In:
  80. ;    ESI - offset of string to display
  81. ; Out:
  82. ;    ?
  83. ;
  84. ; eg db -1
  85. ;    dw x,y
  86. ;    db colour,"Hello",0
  87. ;
  88. ; commands:  -1 start new x,y,colour and text
  89. ;            -2 draw full border starting at x,y to x,y colour offset col
  90. ;            -3 fill within limits x,y  to x,y  colour offset col
  91. ;            -4 draw inside border from x,y to x,y colour offset col
  92. ;            -5 set lower case
  93. ;            -6 set upper case
  94. ;            -7 steel textured box
  95. ;            -8 repeated bitmap box
  96. ;
  97. ; Fill inside full borders 3 smaller than border
  98. ; Fill inside full borders 2 smaller than border to make a "lump"
  99. ; Fill inside "hole" border 2 smaller than hole
  100. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  101.  
  102. tstring:
  103.            push esi                   ; same as string, but does
  104.            call string                ; it to both sides
  105.            call flip_page
  106.            pop esi
  107.            call string
  108.            call flip_page
  109.            ret
  110.  
  111. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  112. ; String: Display string of font from [esi] to zero byte on current video page
  113. ; In:
  114. ;    ESI - offset of string to display
  115. ; Out:
  116. ;    ?
  117. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  118.  
  119. string:
  120.            mov wcase,0                ; default to upper case
  121.  
  122.            cld
  123.            lodsb
  124.            jmp testcommand
  125. freshtext:
  126.            lodsw
  127.            mov bx,ax                  ; x
  128.            lodsw
  129.            mov cx,ax                  ; y
  130.            mov ah,0
  131.            lodsb
  132.            mov dx,ax                  ; colour
  133. textloop:
  134.            lodsb                      ; get character/command
  135. testcommand:
  136.            cmp al,0
  137.            je txnon
  138.  
  139.            cmp al,newtext             ; -1 = 255 = set new x,y,col
  140.            je freshtext
  141.  
  142.            cmp al,border              ; -2 = outside border
  143.            jne n254
  144.            call outside
  145.            jmp textloop               ; ok, i should've used indirect jumps
  146. n254:
  147.            cmp al,fillarea            ; fine, give me a hassle, like i need it!
  148.            jne n253                   ; the code is done, i don't want to
  149.            call dofill                ; change it all now so there!
  150.            jmp textloop
  151. n253:
  152.            cmp al,hole
  153.            jne n252
  154.            call inside
  155.            jmp textloop
  156. n252:
  157.            cmp al,lowercase
  158.            jne n251
  159.            mov wcase,128
  160.            jmp textloop
  161. n251:
  162.            cmp al,uppercase
  163.            jne n250
  164.            mov wcase,0
  165.            jmp textloop
  166. n250:
  167.            cmp al,steelbox
  168.            jne n249
  169.            call steeltext
  170.            jmp textloop
  171. n249:
  172.            cmp al,repeatbit
  173.            jne n248
  174.            call dobitmapthingy
  175.            jmp textloop
  176. n248:
  177.            add al,wcase               ; include which case
  178.            pusha
  179.            char ax,bx,cx,dx
  180.            popa
  181.            movzx edi,ax
  182.            add di,di
  183.            add edi,fontlen
  184.            add bx,[edi]               ; inc to next position
  185.  
  186.            jmp textloop
  187. txnon:
  188.            ret
  189.  
  190. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  191. ; InitFont: Initilize upper and lower case fonts to be used with xmode font stuff
  192. ; In:
  193. ;   ESI -> lowercase font
  194. ;   EDI -> uppercase font
  195. ;   EBP -> font length tables
  196. ; Out:
  197. ;   ?
  198. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  199. initfont:
  200.            mov fontlen,ebp
  201.  
  202.            push esi
  203.            push edi
  204.            pushw 0                    ; initialize font0 block
  205.            call set_display_font
  206.  
  207.            pushw 1                    ; initialize font1 block
  208.            call set_display_font
  209.  
  210.            ret
  211.  
  212. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  213. ;
  214. ; Here is the implementation of some of those cheap font "commands"
  215. ;
  216. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  217.  
  218. borderd    equ 2
  219. borderm    equ 9
  220. borderl    equ 15
  221.  
  222. outside:
  223.            lodsw                      ; draw outside box, get q1,w1  q2,w2
  224.            mov q1,ax                  ; q1,w1 is top left, q2,w2 is bot right
  225.            lodsw
  226.            mov w1,ax
  227.            lodsw
  228.            mov q2,ax
  229.            lodsw
  230.            mov w2,ax
  231.            lodsw
  232.            mov colt,ax
  233.  
  234.            push esi
  235.  
  236.            mov ax,colt
  237.            add ax,borderd+1
  238.            mov linecol,ax
  239.            drawline q1,w1,q1,w2,linecol   ; now draw lines, use macros
  240.            mov ax,colt
  241.            add ax,borderm-1
  242.            mov linecol,ax
  243.            drawline q1,w1,q2,w1,linecol
  244.            mov ax,colt
  245.            add ax,borderm+1
  246.            mov linecol,ax
  247.            drawline q2,w1,q2,w2,linecol
  248.            mov ax,colt
  249.            add ax,borderd+0
  250.            mov linecol,ax
  251.            drawline q1,w2,q2,w2,linecol
  252.  
  253.            inc w1                     ; bump for middle lines
  254.            dec w2
  255.            inc q1
  256.            dec q2
  257.  
  258.            mov ax,colt                ; draw middle lines
  259.            add ax,borderl-1
  260.            mov linecol,ax
  261.            drawline q1,w1,q1,w2,linecol
  262.            mov ax,colt
  263.            add ax,borderl-2
  264.            mov linecol,ax
  265.            drawline q1,w1,q2,w1,linecol
  266.            mov ax,colt
  267.            add ax,borderl-2
  268.            mov linecol,ax
  269.            drawline q2,w1,q2,w2,linecol
  270.            mov ax,colt
  271.            add ax,borderm-1
  272.            mov linecol,ax
  273.            drawline q1,w2,q2,w2,linecol
  274.  
  275.            inc w1                     ; bump for inside lines
  276.            dec w2
  277.            inc q1
  278.            dec q2
  279.  
  280.            mov ax,colt
  281.            add ax,borderd+2
  282.            mov linecol,ax
  283.            drawline q1,w1,q1,w2,linecol   ; draw inner lines
  284.            mov ax,colt
  285.            add ax,borderd+1
  286.            mov linecol,ax
  287.            drawline q1,w1,q2,w1,linecol
  288.            mov ax,colt
  289.            add ax,borderd+0
  290.            mov linecol,ax
  291.            drawline q2,w1,q2,w2,linecol
  292.            mov ax,colt
  293.            add ax,borderl-2
  294.            mov linecol,ax
  295.            drawline q1,w2,q2,w2,linecol
  296.  
  297.            pop esi
  298.            ret
  299.  
  300. dofill:
  301.            lodsw                      ; fill box, get q1,w1  q2,w2
  302.            mov q1,ax                  ; q1,w1 is top left, q2,w2 is bot right
  303.            lodsw
  304.            mov w1,ax
  305.            lodsw
  306.            mov q2,ax
  307.            lodsw
  308.            mov w2,ax
  309.            lodsw
  310.            cmp ax,0
  311.            jne df_ncol
  312.            mov ax,background          ; if colour 0, get background colour
  313. df_ncol:
  314.            mov colt,ax
  315.  
  316.            push esi
  317.            block q1,w1,q2,w2,colt
  318.            pop esi
  319.  
  320.            ret
  321.  
  322. inside:
  323.            lodsw                      ; draw inside box, get q1,w1  q2,w2
  324.            mov q1,ax                  ; q1,w1 is top left, q2,w2 is bot right
  325.            lodsw
  326.            mov w1,ax
  327.            lodsw
  328.            mov q2,ax
  329.            lodsw
  330.            mov w2,ax
  331.            lodsw
  332.            mov colt,ax
  333.  
  334.            push esi
  335.  
  336.            mov ax,colt
  337.            add ax,borderm+1
  338.            mov linecol,ax
  339.            drawline q1,w1,q1,w2,linecol   ; now draw lines, use macros
  340.            mov ax,colt
  341.            add ax,borderd-1
  342.            mov linecol,ax
  343.            drawline q1,w1,q2,w1,linecol
  344.            mov ax,colt
  345.            add ax,borderd+1
  346.            mov linecol,ax
  347.            drawline q2,w1,q2,w2,linecol
  348.            mov ax,colt
  349.            add ax,borderm+2
  350.            mov linecol,ax
  351.            drawline q1,w2,q2,w2,linecol
  352.  
  353.            inc w1                     ; bump for inside lines
  354.            dec w2
  355.            inc q1
  356.            dec q2
  357.  
  358.            mov ax,colt
  359.            add ax,borderm+3
  360.            mov linecol,ax
  361.            drawline q1,w1,q1,w2,linecol   ; now draw lines, use macros
  362.            mov ax,colt
  363.            add ax,borderd+1
  364.            mov linecol,ax
  365.            drawline q1,w1,q2,w1,linecol
  366.            mov ax,colt
  367.            add ax,borderd+2
  368.            mov linecol,ax
  369.            drawline q2,w1,q2,w2,linecol
  370.            mov ax,colt
  371.            add ax,borderl
  372.            mov linecol,ax
  373.            drawline q1,w2,q2,w2,linecol
  374.  
  375.            pop esi
  376.            ret
  377.  
  378. simplesine dw 9,10,11,12,13,14,15,15
  379.            dw 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8
  380.  
  381. steeltext:
  382.            mov ltflag,0               ; make steel textured box (sin wave)
  383.            mov brflag,0
  384.            mov sinewave,0
  385.  
  386.            lodsw
  387.            mov q1,ax
  388.            mov q2,ax
  389.            lodsw
  390.            mov tw1,ax
  391.            lodsw
  392.            mov tq2,ax
  393.            lodsw
  394.            mov w1,ax
  395.            mov w2,ax
  396.            lodsw
  397.            mov linecol,ax
  398.            lodsw
  399.            mov colt,ax
  400. steel_loop:
  401.            mov cx,colt
  402.            add sinewave,cx
  403.            movzx edi,sinewave
  404.            shr di,8
  405.            and di,32*2-2
  406.            mov ax,simplesine[edi]
  407.            add ax,linecol
  408.            mov di,ax
  409.  
  410.            drawline q1,w1,q2,w2,di
  411.  
  412.            mov ax,ltflag
  413.            cmp ax,0
  414.            jne st_doside
  415.  
  416.            dec w1
  417.            mov ax,w1
  418.            cmp ax,tw1
  419.            jne st_dopt2
  420.  
  421.            mov ltflag,1
  422.            jmp st_dopt2
  423. st_doside:
  424.            inc q1
  425. st_dopt2:
  426.            mov ax,brflag
  427.            cmp ax,1
  428.            je st_doup
  429.  
  430.            inc q2
  431.            mov ax,q2
  432.            cmp ax,tq2
  433.            jne st_chkout
  434.  
  435.            mov brflag,1
  436. st_chkout:
  437.            mov ax,q1
  438.            cmp ax,tq2
  439.            jna steel_loop
  440.  
  441.            ret
  442. st_doup:
  443.            dec w2
  444.            jmp st_chkout
  445.  
  446. dobitmapthingy:
  447.            push esi
  448.            lodsd          ; do repeat bitmap
  449.            push eax       ; push bitmap offset (location of bitmap)
  450.            lodsw          ; get x1,y1,x2,y2
  451.            push ax
  452.            lodsw
  453.            push ax
  454.            lodsw
  455.            push ax
  456.            lodsw
  457.            push ax
  458.            call repeat_bitmap
  459.  
  460.            pop esi
  461.            add esi,2+2+2+2+4 ; add for next text instruction
  462.  
  463.            ret
  464.  
  465. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  466. ; Put_at_top: Debugging Tool
  467. ;  In:
  468. ;    Regs - null
  469. ;    number_eax - number to plot at top of screen
  470. ;  Out = in
  471. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  472.  
  473. number_eax dd 0
  474.  
  475. hexs       db "0123456789ABCDEF"
  476.  
  477. top_number db -3
  478.            dw 100,12,220,32,3
  479.            db -1
  480.            dw 107,20
  481.            db 13
  482.            db "EAX="
  483. number     db "00000000",0
  484.  
  485. put_at_top:
  486.            pushad
  487.            mov eax,number_eax
  488.            mov esi,7
  489.            call set_hex
  490.            call set_hex
  491.            call set_hex
  492.            call set_hex
  493.            call set_hex
  494.            call set_hex
  495.            call set_hex
  496.            call set_hex
  497.            mov esi, o top_number
  498.            call string
  499.            popad
  500.            ret
  501. set_hex:
  502.            mov di,ax
  503.            and edi,0fh
  504.            mov bl,hexs[edi]
  505.            mov number[esi],bl
  506.            shr eax,4
  507.            dec si
  508.            ret
  509.  
  510. code32     ends
  511.            end
  512.